﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="../../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <!-- 引用通用的js文件. -->
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../Scripts/layui/layui/layui.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
        var keyOfEn = "";
        var mypk = "";
        var frmID = "";
        var laybase = "../../../";
        //页面启动函数.
        $(function () {
            frmID = GetQueryString("FrmID");
            keyOfEn = GetQueryString("KeyOfEn");
            mypk = frmID + "_" + keyOfEn;
            var en = new Entity("BP.Sys.MapAttr");
            en.SetPKVal(mypk);
            var num = en.RetrieveFromDBSources();
            if (num == 0) {
                layer.alert("字段" + keyOfEn + "信息丢失,请联系管理员");
                return;
            }
            var extPK = "HtmlText_" + mypk;
            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.SetPKVal(extPK);
            var count = mapExt.RetrieveFromDBSources();
            if (count != 0) {
                var doc = mapExt.DoMethodReturnString("ReadBigNoteHtmlText");
                $("#RichText").val(doc);
            }
           
            //显示富文本框
            var images_upload_url = "";
            var handlerUrl = "";
            if (plant == "CCFlow")
                handlerUrl = basePath + "/WF/Comm/Handler.ashx";
            else
                handlerUrl = basePath + "/WF/Comm/Sys/ProcessRequest.do";

            images_upload_url = handlerUrl + '?DoType=HttpHandler&DoMethod=RichUploadFile';
            images_upload_url += '&HttpHandlerName=BP.WF.HttpHandler.WF_Comm_Sys&FrmID=' + frmID + "&WorkID=0";
            layui.extend({
                tinymce: '../../../Scripts/layui/ext/tinymce/tinymce'
            }).use('tinymce', function () {
                var tinymce = layui.tinymce;
                var h = $("#RichText").height();
                //if (h < 400) h = 400;
                tinymce.render({
                    elem: "#RichText"
                    , height: h
                    , images_upload_url: images_upload_url
                    , paste_data_images: true
                    //取消默认提示
                   
                });

            });

        });
        function Save() {
            var edit = layui.tinymce.get("#RichText");
            var val = edit.getContent();
            //获取富文本的内容
            if (val == "") {
                alert("内容不能为空！");
                return;
            }
            //扩展属性
            var extPK = "HtmlText_" + mypk;
            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.SetPKVal(extPK);
            var count = mapExt.RetrieveFromDBSources();
            if (count == 0) {
                mapExt.MyPK = extPK;
                mapExt.FK_MapData = frmID;
                mapExt.ExtType = "HtmlText";
                mapExt.AttrOfOper = keyOfEn;
                mapExt.Insert();
            }
            var msg = mapExt.DoMethodReturnString("SaveBigNoteHtmlText", val);
            layer.alert(msg);
        }
        function Delete() {
            //删除字段、文件
            var en = new Entity("BP.Sys.MapAttr", mypk);
            en.Delete();
            if (parent.layer)
                parent.layer.close(parent.layer.index);
            else {
                window.close();
                parent.$("#eudlg").dialog('close');
            }
        }

        function Reset() {
            var edit = layui.tinymce.get("#RichText");
            edit.setContent("");
           
        }

        </script>
</head>
<body>
    <div style='white-space:normal;margin:8px'>
        <h3> 编辑提示信息 </h3>
        <textarea style="height:calc(100vh - 100px);width:100%;" id="RichText"></textarea>
    </div>
    <br />
    <button type="button" class="layui-btn layui-btn-primary"  onclick="Save();" >保存</button>
    <button type="button" class="layui-btn layui-btn-primary"  onclick="Reset();">重置</button>
    <button type="button" class="layui-btn layui-btn-primary"  id="deleteBtn" onclick="Delete();">删除字段</button>
</body>
</html>